package com.molyfun.parents.activity.course.view.courseitem;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import com.molyfun.parents.MFPApplication;
import com.molyfun.parents.activity.course.bean.CourseMediaBean;
import com.molyfun.parents.dao.gen.DaoMaster;
import com.molyfun.parents.dao.gen.DaoSession;
import com.molyfun.parents.dao.gen.SingleDownloadTaskDao;
import com.molyfun.parents.utils.Const;

/**
 * Created by william(liuchao.hit@gmail.com).
 * Date:11/30/16.
 */
public class BaseCourseView extends LinearLayout {

    protected CourseMediaBean mCourseMediaBean;

    protected SingleDownloadTaskDao singleDownloadTaskDao;

    public BaseCourseView(Context context, AttributeSet attrs, int defStyle) {
        this(context, attrs);
    }

    public BaseCourseView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BaseCourseView(Context context) {
        super(context);
    }

    public void initData(CourseMediaBean courseMediaBean){
        this.mCourseMediaBean = courseMediaBean;
        if(mCourseMediaBean != null){
//            if(mCourseMediaBean.isOffLineMode()){
                DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(MFPApplication.getInstance(), Const.DB_NAME, null);
                DaoMaster daoMaster = new DaoMaster(devOpenHelper.getWritableDatabase());
                DaoSession daoSession = daoMaster.newSession();
                singleDownloadTaskDao = daoSession.getSingleDownloadTaskDao();
//            }
        }
    }

}
